package routers

import (
	"chapter6/controllers"

	beegoWeb "github.com/beego/beego/v2/server/web"
)
/**
 * Created with Goland.
 * User: 令狐飞侠
 * Date: 2022-3-10
 * Description: 路由的函数
 */
func init() {
	beegoWeb.Router("/", &controllers.MainController{})

	//hello world
	beegoWeb.Get("/hello", controllers.DoHello)

	//简单分组路由
	beegoWeb.Router("/buy", &controllers.BuyerController{})
	beegoWeb.Router("/shopper", &controllers.SellerController{})

	//orm路由
	userNS := beegoWeb.NewNamespace("/user",
		beegoWeb.NSRouter("/list", &controllers.UerController{},"get:ListUser"),
		beegoWeb.NSRouter("/add", &controllers.UerController{},"get:AddUser"),
		beegoWeb.NSRouter("/del", &controllers.UerController{},"get:DelUser"),
		beegoWeb.NSRouter("/update",  &controllers.UerController{},"get:UpdateUser"),
	)


	beegoWeb.AddNamespace(userNS)

}
